<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
    <script>
        let data = {
            msg:'hello'
        }
        let vm = {}
        // 对象的属性
        Object.defineProperty(vm,'msg',{
            enumerable:true,
            configurable:true,
            get(){
                return data.msg
            },
            set(newVal){
                if(newVal === data.msg) return 
                data.msg = newVal
                //数据更改，更新DOM值
                document.querySelector('#app').textContent = data.msg
            }
        })
        vm.msg = 'hehe'
    </script>
</body>
</html>